//
//  ViewController.m
//  LinePra
//
//  Created by 李江湖 on 2018/7/27.
//  Copyright © 2018年 李江湖. All rights reserved.
//

#import "ViewController.h"
#import "JHBezierView.h"
@interface ViewController ()
@property (nonatomic,strong)JHBezierBgView *bgBezier;
@property (weak, nonatomic) IBOutlet UIButton *typeBtn;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGBA(21, 31, 53, 1);
    // Do any additional setup after loading the view, typically from a nib.

}
- (IBAction)typeClick:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected) {
        [sender setTitle:@"柱状图" forState:0];
        self.bgBezier.bezier.graphicsType = ColumnGraphicsType;
        
    }else{
        [sender setTitle:@"曲线图" forState:0];
        self.bgBezier.bezier.graphicsType = CurveGraphicsType;
        
    }
}

- (IBAction)btnClick:(UIButton *)sender {
    [self.bgBezier removeFromSuperview];
//    使用规则：showDay必须为5的整数倍，
    
    self.bgBezier = [[JHBezierBgView alloc]initWithFrame:CGRectMake(20, 100, 320, 320)];
    self.bgBezier.backgroundColor = RGBA(28, 43, 70, 1);
    self.bgBezier.bezier.backgroundColor = RGBA(28, 43, 70, 1);
    [self.view addSubview:self.bgBezier];
 
    self.bgBezier.bezier.shaftColor = [UIColor grayColor];
    self.bgBezier.bezier.dottedLineColor = [UIColor yellowColor];
    self.bgBezier.bezier.layer.cornerRadius = 5;
    if (self.typeBtn.selected) {
        self.bgBezier.bezier.graphicsType = ColumnGraphicsType;
        
    }else{
        self.bgBezier.bezier.graphicsType = CurveGraphicsType;
        
    }
//    self.bezier.bezier.layer.masksToBounds = YES;
    if (sender.tag == 10) {
        self.bgBezier.bezier.lineType = BrokenLineType;
        self.bgBezier.bezier.showLine = YES;
        self.bgBezier.bezier.isMask = NO;
        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10),@(10.5),@(11),@(10.6),@(10.5),@(10.0),@(10.9),@(11.2),@(10),@(10.5),@(10)]];

        [self.bgBezier.bezier setUpTheDate:@"2018-08-08" yMin:9.5 yMax:(9.5 + (0.25*7)) showDay:10 numType:NO];
    }else if (sender.tag == 11){
        self.bgBezier.bezier.lineType = DottedCurveLineType;
        self.bgBezier.bezier.showLine = YES;
        self.bgBezier.bezier.isMask = NO;
        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10), @(9.5), @(9.90), @(10), @(11), @(9.8), @(9.70), @(10.4), @(10.3), @(10.2), @(9.60)]];
        [self.bgBezier.bezier setUpTheDate:@"2018-08-08" yMin:9.5 yMax:(9.5 + (0.25*7)) showDay:10 numType:NO];
    }else if (sender.tag == 12){
        self.bgBezier.bezier.lineType = CurveLineType;
        self.bgBezier.bezier.showLine = NO;
        self.bgBezier.bezier.isMask = YES;
        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10), @(9.5), @(9.90), @(10), @(11), @(9.8), @(9.70), @(10.4), @(10.3), @(10.2), @(9.60)]];
        [self.bgBezier.bezier setUpTheDate:@"2018-08-08" yMin:9.5 yMax:(9.5 + (0.25*7)) showDay:10 numType:NO];
    }else if (sender.tag == 13){
        self.bgBezier.bezier.lineType = BrokenLineType;
        self.bgBezier.bezier.showLine = YES;
        self.bgBezier.bezier.isMask = YES;
        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10), @(9.5), @(9.90), @(10), @(11), @(9.8), @(9.70), @(10.4), @(10.3), @(10.2), @(11.25)]];
  
        [self.bgBezier.bezier setUpTheDate:@"2018-08-08" yMin:9.5 yMax:(9.5 + (0.25*7)) showDay:10 numType:NO];
    }else if (sender.tag == 14){
        //多个曲线
        self.bgBezier.bezier.lineType = CurveLineType;
        self.bgBezier.bezier.showLine = YES;
        self.bgBezier.bezier.isMask = YES;
        self.bgBezier.bezier.lineColor = [UIColor greenColor];
        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10), @(9.5), @(9.90), @(10), @(11), @(9.8), @(9.70), @(10.4), @(10.3), @(10.2), @(9.60)]];
        self.bgBezier.bezier.pointYArrayAdd = [NSMutableArray arrayWithArray:@[@[@(9.7),@(10.5),@(11),@(10.6),@(10.5),@(10.2),@(10.9),@(11.2),@(10),@(10.5),@(10)],@[@(11),@(10.9),@(9.5),@(10.4),@(10.1),@(10.0),@(10.9),@(11.0),@(10.6),@(10.5),@(11)],@[@(10.1),@(10.0),@(10.9),@(11.0),@(10.6),@(10.5),@(11),@(11),@(10.9),@(9.5),@(10.4)],@[@(10.0),@(10.9),@(11.0),@(10.6),@(10.5),@(11),@(10.9),@(9.5),@(10.4),@(10.1),@(11)]]];

        [self.bgBezier.bezier setUpTheDate:@"2018-08-08" yMin:9.5 yMax:(9.5 + (0.25*7)) showDay:10 numType:NO];
    }else if (sender.tag == 15){
        //近6天
        self.bgBezier.bezier.lineType = BrokenLineType;
        self.bgBezier.bezier.fillTopColor = RGBA(138, 128, 84, 1);
        self.bgBezier.bezier.fillBottomColor = RGBA(138, 128, 84, 0.3);
        self.bgBezier.bezier.showLine = YES;
        self.bgBezier.bezier.isMask = NO;

        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10), @(9.5), @(9.90), @(10), @(11), @(9.8)]];
        [self.bgBezier.bezier setUpTheDate:@"2018-08-08" yMin:9.5 yMax:(9.5 + (0.25*7)) showDay:5 numType:NO];
    }else if (sender.tag == 16){
//        近一个月
        self.bgBezier.bezier.lineType = CurveLineType;
        self.bgBezier.bezier.showLine = YES;
        self.bgBezier.bezier.isMask = NO;

        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(11), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8)]];
        [self.bgBezier.bezier setUpTheDate:@"2018-08-08" yMin:9.5 yMax:(9.5 + (0.25*7)) showDay:30 numType:NO];
        
    }else if (sender.tag == 17){
//        近两个月
//        self.bgBezier.bezier.lineType = DottedCurveLineType;
        self.bgBezier.bezier.showLine = YES;
        self.bgBezier.bezier.isMask = NO;

        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(11), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(11), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8)]];
        [self.bgBezier.bezier setUpTheDate:@"2018-08-08" yMin:9.5 yMax:(9.5 + (0.25*7)) showDay:60 numType:NO];
    }else if (sender.tag == 18){
//        近三个月
        self.bgBezier.bezier.lineType = DottedCurveLineType;
        self.bgBezier.bezier.showLine = YES;
        self.bgBezier.bezier.isMask = YES;
        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(11), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(11), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(11), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8)]];
        [self.bgBezier.bezier setUpTheDate:@"2018-08-08" yMin:9.5 yMax:(9.5 + (0.25*7)) showDay:90 numType:NO];
    }else if (sender.tag ==19){
        //平价
        self.bgBezier.bezier.lineType = BrokenLineType;
        self.bgBezier.bezier.fillTopColor = RGBA(138, 128, 84, 1);
        self.bgBezier.bezier.fillBottomColor = RGBA(138, 128, 84, 0.3);
        self.bgBezier.bezier.showLine = NO;
        self.bgBezier.bezier.isMask = YES;
        self.bgBezier.bezier.isAllEqual = YES;
        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10), @(10), @(10), @(10), @(10), @(10)]];
        [self.bgBezier.bezier setUpTheDate:@"2018-08-08" yMin:10-0.25 yMax:10+0.25 showDay:5 numType:NO];
    }else if (sender.tag == 20){

        self.bgBezier.bezier.lineType = CurveLineType;
        self.bgBezier.bezier.showLine = YES;
        self.bgBezier.bezier.isMask = NO;
        self.bgBezier.bezier.pointYArray = [NSMutableArray arrayWithArray:@[@(10), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8), @(9.7), @(9.90), @(10), @(11), @(9.8), @(9.7), @(9.90), @(10), @(10.25), @(9.8)]];//设置y轴的值
        
        [self.bgBezier.bezier setxMin:0 xMax:10 yMin:8 yMax:12];//设置x、y轴的最大最小值
    }

   
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
